package com.erpx.api.goods;

import com.erpx.api.WdtClient;
import com.erpx.api.param.SysGoodsCreateParam;
import com.erpx.api.param.SysGoodsSpecCreateParam;
import com.erpx.utils.JsonUtils;
import com.erpx.api.CommonConstants;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GoodsCreateService {
    public static void goodsPush() throws Exception {
        WdtClient client = new WdtClient(CommonConstants.sid, CommonConstants.appkey, CommonConstants.appSecret, CommonConstants.baseUrl);

        Map<String, String> params = new HashMap<String, String>();
        List<SysGoodsCreateParam> list = new ArrayList<>();
        SysGoodsCreateParam param = new SysGoodsCreateParam();
        param.setGoodsNo("T20240805001");
        param.setGoodsName("商城测试1");
        SysGoodsSpecCreateParam specCreateParam = new SysGoodsSpecCreateParam();
        specCreateParam.setSpecNo("SPE20240805001");
        specCreateParam.setSpecName("商城测试sku1");
        List<SysGoodsSpecCreateParam> specLit = new ArrayList<>();
        specLit.add(specCreateParam);
        param.setSpecList(specLit);
        list.add(param);
        params.put("goods_list", JsonUtils.serialize(list));
        try {
            String response = client.execute("goods_push.php", params);
            System.out.println(response);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
